package com.app.signing.utils

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.app.signing.app.logi
import com.app.signing.data.DbManager
import com.app.signing.data.SpManager
import com.app.signing.view.signin.SignInActivity

class EndSigningReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        "接收到静态广播--${intent.action}".logi()
        if (intent.action == SignInActivity.RECEIVER_SIGNING_END_ACTION) {
            // 删除及结束保存的相关数据
            val signingId = SpManager.INSTANCE.readSigningDataId()
            if (signingId == -1L) {
                return
            }
            DbManager.INSTANCE.finishSigning(signingId)
            SpManager.INSTANCE.deleteSigningDataId()
            DbManager.INSTANCE.finishSeat(signingId)
        }
    }
}
